﻿using System;
using System.Reflection;
using Douban.Api.Infrastructure;
using Douban.Api.Tests.Support;
using Moq;

namespace Douban.Api.Tests.Mocks
{
    public class MockDataSourcePool : IDataSourcePool
    {
        public T GetDataSource<T>(string sourceId) where T : IDataSource
        {
            return Activator.CreateInstance<T>();
        }

        public IDataSource GetDataSource(string sourceId, Type originType)
        {
            var mock = new Mock<IDataSource>();
            mock.Setup(ds => ds.Source)
                .Returns(ResourceLoader.GetResource(originType.Name + ".xml"));

            return mock.Object;
        }
    }
}
